package com.zcf.controller;


import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.zcf.common.json.Body;
import com.zcf.pojo.Mall;
import com.zcf.service.MallImpl;
import com.zcf.vo.out.LayuiJson;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author ZhaoQi
 * @since 2019-03-18
 */
@CrossOrigin
@Controller
@RequestMapping("/mall")
public class MallController {

	@Autowired
	MallImpl mi;
	/**
	 * 前端获取商场信息
	 * @return
	 */
	@PostMapping(value="getMall")
	@ResponseBody
	public Body getMall(@RequestParam(value = "userid") int userid){
		return mi.getMall(userid);
	}
	
	/**
	 *后端获取商场信息
	 * @return
	 */
	@PostMapping("getMalls")
	@ResponseBody
	public LayuiJson getMalls(@RequestParam(value = "pageNum")int pageNum, 
			 @RequestParam(value = "pageSize") int pageSize){
		return mi.getMalls(pageNum,pageSize);
	}
	/**
	 * 更改商城钻石、金额
	 * @param mall
	 * @return
	 */
	@PostMapping("updatemall")
	@ResponseBody
	public Body updatemall(Mall mall){
		return mi.updatemall(mall);
	}
	/**
	 * 删除商城一个记录
	 * @param mall
	 * @return
	 */
	@PostMapping("delete")
	@ResponseBody
	public Body delete(Mall mall){
		return mi.delete(mall);
	}
	/**
	 * 添加商城钻石金额
	 * @param mall
	 * @return
	 */
	@PostMapping("add")
	@ResponseBody
	public Body add(Mall mall){
		return mi.add(mall);
	}
	
}

